package net.huashitong.Indicators.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import net.huashitong.Indicators.entity.TwoIndex;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TwoIndexDao extends StringDao<TwoIndex> {
    /**
     * 通过codeId查询
     * @param codeId
     * @return
     */
    public TwoIndex queryByCodeId(String codeId){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.codeId=:codeId").setParam("codeId", codeId);
        return query.firstResult();
    }

    /**
     * 通过上级指标Code 查询
     * @param parentCode
     * @return
     */
    public List<TwoIndex> queryByParentCode(String parentCode){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.parentCode=:parentCode").setParam("parentCode", parentCode);
        return query.listResult();
    }

}
